/*
 * @Description: 描述多个请求，根据请求先后顺序执行回调
 * @Author: wangchao
 * @Date: 2023-02-06 14:18:25
 */

function gatherPromises(arr) {

  Promise.race(arr).then(res=>{
    console.log(res);
  })
  
}

async function get1(params) {
 return  await new Promise((resolve,reject)=>{
    setTimeout(() => {
      resolve(1)
    }, 1000);
  })
}
async function get2(params) {
  return await new Promise(resolve=>{
    setTimeout(() => {
      resolve(2)
    }, 2000);
  })
}

gatherPromises([get1(),get2()])